package model.map;

import java.util.*;

/**
 * This class is used to represent a tree of MapPoints.
 * @author Zachary
 */
public class MapPointTreeNode {
	private List<MapPointTreeNode> children;
	private MapPoint mapPoint;
	
	/**
	 * Constructor for a MapPointTreeNode.
	 * @param point
	 */
	public MapPointTreeNode(MapPoint point){
		this.children = new ArrayList<MapPointTreeNode>();
		this.mapPoint = point;
	}
	
	/**
	 * Adds a child to the MapPointTreeNode.
	 * @param node
	 */
	public void addChild(MapPointTreeNode node){
		this.children.add(node);
	}
	
	/**
	 * Removes all of the children of the MapPointTreeNode.
	 */
	public void destroyChildren(){
		for(int i = 0;i<children.size();i++)
			children.remove(i);
	}
	
	/**
	 * Returns the children of the node.
	 * @return
	 */
	public List<MapPointTreeNode> getChildren(){
		return this.children;
	}
	
	/**
	 * Gets the MapPoint of this MapPointTreeNode.
	 * @return
	 */
	public MapPoint getMapPoint(){
		return this.mapPoint;
	}
	
	/**
	 * Returns an iterator over the node's children.
	 * @return
	 */
	public Iterator<MapPointTreeNode> createChildIter() {
		return this.children.iterator();
	}
}
